<html>
    <head>
        
        <title>Home page</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <style type="text/css">
            select{
                padding: 3px;
                border: 1px solid #ccc;
                background: #fff;
            }
            .header-set select{
                padding: 5px 5px 5px 15px;
                width: 250px;
            }
            table td{
                padding: 3px;
                margin: 1px 3px;
            }
            #set input{
                border: 1px solid #ccc;
                border-radius: 0px;
                background: #fff;
                padding: 5px 20px;
                color:#000;
            }
            .header-set{
                padding: 10px 0px;
                border-bottom: 1px solid #ccc;
                margin: 10px 0px;
            }
        </style>
          
    </head>
    <body>
        <div id="wraper">
            <?php $this->load->view('admin/menu', array('action' => $action)); ?>
            <div id="content">
                <div style="margin: auto;">
                    <center>
                    <form method="post">
                    <div class="form-group">
                    </div>
                        <br>
                        <table>
                            <tr>
                                <td colspan="4" class="header-set">
                                    <select name="site" class="form-control" onchange="location.href ='<?php echo base_url('admin/set_categories/site'); ?>'+'/'+this.value">
                                        <option value="0">Select sites</option>
                                        <?php foreach ($sites as $item): ?>
                                            <option value="<?php echo $item['id']; ?>" <?php if (isset($array_segments['site']) && $item['id'] == $array_segments['site']) echo 'selected=selected' ?>>
                                                <?php echo $item['name'] ?>
                                            </option>
                                        <?php endforeach; ?>
                                    </select>
                                 <span id="set">
                                    <input type="submit" name="submit" value="set">
                                 </span>
                                 
                                </td>
                                
                                <td colspan="3" align="right" class="header-set">
                                    <b>
                                        <?php
                                        foreach ($sites as $item) {
                                            if ($array_segments['site'] == $item['id'])
                                                echo $item['name'];
                                        }
                                        ?>
                                    </b>
                                    &raquo; Total: <?php echo count($all_categories); ?>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding: 10px;"></td>
                            </tr>
                            <?php for ($i=0; $i<count($all_categories)-1; $i+=2):?>
                            
                                <tr>
                                    <td style="color: darkcyan;"> <?php if(!empty($all_categories[$i]['id_category'])) echo '&check;' ;?></td>
                                    <td>
                                       
                                        <?php echo $all_categories[$i]['name'] ?>
                                        <input type="hidden" name="categories[]" value="<?php echo $all_categories[$i]['id'] ?>">
                                    </td>
                                    <td>
                                        <select name="ref[]">
                                            <option value="">none</option>
                                            <?php foreach ($categories as $category): ?>
                                            <option value="<?php echo $category['id']?>" <?php if($all_categories[$i]['id_category']==$category['id']) echo 'selected=selected' ?>> <?php echo $category['name'] ?></option>
                                            <?php endforeach; ?>
                                        </select>
                                    </td>
                                    <td>&nbsp; &nbsp; </td>
                                    <td style="color: darkcyan;"> <?php if(!empty($all_categories[$i]['id_category'])) echo '&check;' ;?></td>
                                     <td>
                                        <?php echo $all_categories[$i+1]['name'] ?>
                                        <input type="hidden" name="categories[]" value="<?php echo $all_categories[$i+1]['id'] ?>">
                                    </td>
                                    <td>
                                        <select name="ref[]">
                                            <option value="">none</option>
                                            <?php foreach ($categories as $category): ?>
                                            <option value="<?php echo $category['id']?>" <?php if($all_categories[$i+1]['id_category']==$category['id']) echo 'selected=selected' ?>> <?php echo $category['name'] ?></option>
                                            <?php endforeach; ?>
                                        </select>
                                    </td>
                                </tr>
                            <?php endfor; ?>
                        </table>
                        
                    </center>   
                </div>
            </div><!-- End #Content -->
            <?php $this->load->view('admin/footer'); ?>
            </div>
    </body>
</html>

